package com.ruoyi.system.controller;

import java.util.List;

import com.ruoyi.system.domain.backend.SafetyExaminationInfoDate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SafetyExaminationInfo;
import com.ruoyi.system.service.ISafetyExaminationInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考试信息Controller
 * 
 * @author ruoyi
 * @date 2021-04-07
 */
@RestController
@RequestMapping("/system/examinationinfo")
public class SafetyExaminationInfoController extends BaseController
{
    @Autowired
    private ISafetyExaminationInfoService safetyExaminationInfoService;

    /**
     * 查询考试信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:examinationinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(SafetyExaminationInfo safetyExaminationInfo)
    {
        List<SafetyExaminationInfo> list = safetyExaminationInfoService.selectSafetyExaminationInfoList(safetyExaminationInfo);
        return getDataTable(list);
    }

    /**
     * 导出考试信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:examinationinfo:export')")
    @Transactional
    @Log(title = "考试信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SafetyExaminationInfo safetyExaminationInfo)
    {
        List<SafetyExaminationInfo> list = safetyExaminationInfoService.selectSafetyExaminationInfoList(safetyExaminationInfo);
        ExcelUtil<SafetyExaminationInfo> util = new ExcelUtil<SafetyExaminationInfo>(SafetyExaminationInfo.class);
        return util.exportExcel(list, "examinationinfo");
    }

    /**
     * 获取考试信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:examinationinfo:query')")
    @GetMapping(value = "/{safetyExaminationId}")
    public AjaxResult getInfo(@PathVariable("safetyExaminationId") String safetyExaminationId)
    {
        return AjaxResult.success(safetyExaminationInfoService.selectSafetyExaminationInfoById(safetyExaminationId));
    }

    /**
     * 新增考试信息
     */
    @PreAuthorize("@ss.hasPermi('system:examinationinfo:add')")
    @Log(title = "考试信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SafetyExaminationInfoDate safetyExaminationInfo)
    {
        return toAjax(safetyExaminationInfoService.insertSafetyExaminationInfo(safetyExaminationInfo));
    }

    /**
     * 修改考试信息
     */
    @PreAuthorize("@ss.hasPermi('system:examinationinfo:edit')")
    @Log(title = "考试信息", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody SafetyExaminationInfoDate safetyExaminationInfo)
    {
        return toAjax(safetyExaminationInfoService.updateSafetyExaminationInfo(safetyExaminationInfo));
    }

    /**
     * 删除考试信息
     */
    @PreAuthorize("@ss.hasPermi('system:examinationinfo:remove')")
    @Log(title = "考试信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{safetyExaminationIds}")
    public AjaxResult remove(@PathVariable String[] safetyExaminationIds)
    {
        return toAjax(safetyExaminationInfoService.deleteSafetyExaminationInfoByIds(safetyExaminationIds));
    }
}
